package com.adaxi.adc.business.vehicletrip.controller;


import com.adaxi.adc.business.vehicletrip.feign.service.IExampleFeignService;
import com.adaxi.adc.business.vehicletrip.pojo.VehiclePassengerTrip;
import com.adaxi.adc.common.common.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/vehiclePassenger")
public class VehiclePassengerTripController {



    @Autowired
    IExampleFeignService iExampleFeignService;

    @GetMapping("/query")
    public CommonResult query() {
        try {
            CommonResult<VehiclePassengerTrip> list = iExampleFeignService.query();
            return CommonResult.SUCCESS("查询全部信息", list);
        }catch (Exception e){
            return CommonResult.FAILURE("失败");
        }


    }

    /**
     * 获取全部passenger信息
     * @return
     */
    @GetMapping
    public CommonResult listAll(){
            CommonResult vpt = iExampleFeignService.listAll();
            return vpt;
    }

    /**
     * 司机取消行程
     * 通过vid删除乘客的订单信息
     * @param vid
     * @return
     */
    @DeleteMapping("/cancel/{vid}")
    public CommonResult deleteByVId(@PathVariable String vid){
        iExampleFeignService.deleteById(vid);
        return CommonResult.SUCCESS("删除成功");
    }

    /**
     * 订单详情
     * 通过vtid查询同一订单下的乘客信息
     * @param vtid
     * @return
     */
    @GetMapping("/{vtid}")
    public CommonResult listByVTId(@PathVariable("vtid") String vtid){
        CommonResult vptid = iExampleFeignService.listByVTId(vtid);
        return vptid;
    }



}
